package com.bhs.sansonglogistics.ui.adapter;

import android.text.Html;
import android.text.Spanned;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.OrderGoodsBean;
import com.bhs.sansonglogistics.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * 运单信息
 */
public class WaybillOrderAdapter extends BaseQuickAdapter<OrderGoodsBean, BaseViewHolder> {

    private int type = 1;//2可编辑

    public WaybillOrderAdapter(int type) {
        super(R.layout.item_order_info);
        this.type=type;
    }

    public WaybillOrderAdapter() {
        super(R.layout.item_order_info);
    }


    //订单号:1187910264 蔬菜/10件/10吨/100方 送货上门
    @Override
    protected void convert(@NonNull BaseViewHolder helper, OrderGoodsBean item) {
        String info = String.format(" %s/%s件/%s吨/%s立方 %s", item.getGoods_name(), item.getGoods_number(), item.getGoods_weight(), item.getGoods_volume(), MyUtils.getDistributionType(item.getPeisong_type()));
        Spanned licensePlateNumber = Html.fromHtml("订单号:<font color=\"#485EF4\">" + item.getDeliver_sn() + "</font>" + info);
        helper.setText(R.id.tv_content, licensePlateNumber);
        helper.setGone(R.id.iv_delete, type == 2);
        helper.addOnClickListener(R.id.iv_delete);
    }
}
